/* 2017-9-28 16:04:24  */
//模块：
LArk.widget.bindClass(LArk.widget.BaseWidget.extend({
    options: {
        resources: ['view.css'],
        //弹窗
        view: {
            type: "divwindow",
            url: "view.html",
            windowOptions: {
                width: 230,
                height: 140
            }
        },
    },
    //初始化[仅执行1次]
    create: function () {

    },
    arrPoint: [],
    //每个窗口创建完成后调用
    winCreateOK: function (opt, result) {
        var that = this;
        var center = LArk.point.getCenter(that.viewer);
        var divpoint = new LArk.DivPoint(that.viewer, {
            html: `<div class="divpoint1">
                    <div class="title">测试DIV点1</div>
                  </div >`,
            position: Cesium.Cartesian3.fromDegrees(center.x, center.y, center.z || 424),
            anchor: [0, 0],
            oldver:true,
            click: function (e) {//单击后的回调
                haoutil.msg('单击了点');
            },
        });
        this.arrPoint.push(divpoint);
        var divpoint = new LArk.DivPoint(that.viewer, {
            html: `<div class="divpoint2">
                    <div class="title">测试DIV点2</div>
                    <div class="content">此处可以绑定任意Html代码和css效果</div> 
                  </div >`,
            position: Cesium.Cartesian3.fromDegrees(center.x + 0.05, center.y + 0.05, center.z || 424),
            anchor: [0, 0],
            oldver:true,
            click: function (e) {//单击后的回调
                haoutil.msg('单击了点');
            },
        });
        this.arrPoint.push(divpoint);

        $('#drawPointFn').on('click',function() {
            that.drawPoint()
        })
        $('#clearDrawFn').on('click',function() {
            that.clearDraw()
        })
    },
    //打开激活
    activate: function () {
        
    },
    drawPoint() {
        var that = this;
        that.viewer.LArkgis.draw.deleteAll();
        that.viewer.LArkgis.draw.startDraw({
            type: "point",
            style: {
                pixelSize: 12,
                color: '#ffff00'
            },
            success: function (entity) {
                var position = entity.position.getValue();
                that.viewer.LArkgis.draw.deleteAll();
                var divpoint = new LArk.DivPoint(that.viewer, {
                    html: `<div class="divpoint2">
                        <div class="title">测试DIV点</div>
                        <div class="content">此处可以绑定任意Html代码和css效果</div> 
                    </div >`,
                    position: position,
                    anchor: [0, 0],
                    oldver:true,
                    click: function (e) {//单击后的回调
                        haoutil.msg('单击了点');
                    },
                });
                that.arrPoint.push(divpoint);
            }
        });
    },
    clearDraw() {
        this.viewer.LArkgis.draw.deleteAll();
        for (var i = 0, len = this.arrPoint.length; i < len; i++) {
            this.arrPoint[i].destroy();
        }
        this.arrPoint = [];
    },
    //关闭释放
    disable: function () {
        this.viewWindow = null;

    },



}));

